package com.dhcc.bpm.business.papc.service.impl;

////import com.baomidou.dynamic.datasource.annotation.DS;
import com.dhcc.bpm.business.papc.entity.PrdtInfo;
import com.dhcc.bpm.business.papc.vo.PrdtInfoVO;
import com.dhcc.bpm.business.papc.mapper.PrdtInfoMapper;
import com.dhcc.bpm.business.papc.service.IPrdtInfoService;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.util.StringUtils;
import java.util.List;

/**
 * 产品基础信息  服务实现类
 *
 * @author liuzhao
 * @since 2020-05-16
 */
@Service
//@DS("slave")
public class PrdtInfoServiceImpl extends BaseServiceImpl<PrdtInfoMapper, PrdtInfo> implements IPrdtInfoService {

    @Override
    public IPage<PrdtInfoVO> selectPrdtInfoPage(IPage<PrdtInfoVO> page, PrdtInfoVO prdtInfo) {
        return page.setRecords(baseMapper.selectPrdtInfoPage(page, prdtInfo));
    }

    @Override
    public PrdtInfo selectPrdtInfoById(Long id) {
        return baseMapper.selectPrdtInfoById(id);
    }

    @Override
    public boolean saveOrUpdate(PrdtInfo prdtInfo) {
        int result;
        if (StringUtils.isEmpty(prdtInfo.getId())) {
            result = baseMapper.save(prdtInfo);
        } else {
            prdtInfo.setPrdtInfoKey(prdtInfo.getId().toString());
            result = baseMapper.update(prdtInfo);
        }
        return result >= 1;
    }

    @Override
    public boolean deletePrdtInfoByIds(String ids) {
        int result = baseMapper.deletePrdtInfoByIds(ids.split(","));
        return result >= 1;
    }

    @Override
    public List<PrdtInfo> selectPrdtInfoAll(PrdtInfo prdtInfo) {
        return baseMapper.selectPrdtInfoAll(prdtInfo);
    }
}
